+2008-03-12 Tor Lillqvist <tml@novell.com>
+
+ Bug 510000 - GtkStatusIcon doesn't reshow after explorer.exe crash
+
+ * gtk/gtkstatusicon.c [Win32]: Keep a list of status icons. Check
+ for the TaskbarCreated message in the window procedure for the
+ dummy "tray observer" window we create. When we get a
+ TaskbarCreated message, iterate over the status icons and re-add
+ them to the task bar, and update them by calling
+ gtk_status_icon_update_image().
+
+ Move some ifdefs around to avoid unused functions.
+
2008-03-12 Tor Lillqvist <tml@novell.com>
* config.h.win32.in: Update to match what configure produces.
static void gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon);
static void gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon);
-#endif
static gboolean gtk_status_icon_key_press (GtkStatusIcon *status_icon,
GdkEventKey *event);
static void gtk_status_icon_popup_menu (GtkStatusIcon *status_icon);
+#endif
static gboolean gtk_status_icon_button_press (GtkStatusIcon *status_icon,
GdkEventButton *event);
static void gtk_status_icon_disable_blinking (GtkStatusIcon *status_icon);
static void gtk_status_icon_reset_image_data (GtkStatusIcon *status_icon);
-
+static void gtk_status_icon_update_image (GtkStatusIcon *status_icon);
G_DEFINE_TYPE (GtkStatusIcon, gtk_status_icon, G_TYPE_OBJECT)
return FALSE;
}
+static UINT taskbar_created_msg = 0;
+static GSList *status_icons = NULL;
+
static LRESULT CALLBACK
wndproc (HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam)
{
+ if (message == taskbar_created_msg)
+ {
+ GSList *rover;
+
+ for (rover = status_icons; rover != NULL; rover = rover->next)
+ {
+ GtkStatusIcon *status_icon = GTK_STATUS_ICON (rover->data);
+ GtkStatusIconPrivate *priv = status_icon->priv;
+
+ priv->nid.hWnd = hwnd;
+ priv->nid.uID = GPOINTER_TO_UINT (status_icon);
+ priv->nid.uCallbackMessage = WM_GTK_TRAY_NOTIFICATION;
+ priv->nid.uFlags = NIF_MESSAGE;
+
+ if (!Shell_NotifyIconW (NIM_ADD, &priv->nid))
+ {
+ g_warning ("%s:%d:Shell_NotifyIcon(NIM_ADD) failed", __FILE__, __LINE__-2);
+ priv->nid.hWnd = NULL;
+ continue;
+ }
+
+ gtk_status_icon_update_image (status_icon);
+ }
+ return 0;
+ }
+
if (message == WM_GTK_TRAY_NOTIFICATION)
{
ButtonCallbackData *bc;
if (hwnd)
return hwnd;
+ taskbar_created_msg = RegisterWindowMessage("TaskbarCreated");
+
memset (&wclass, 0, sizeof(WNDCLASS));
wclass.lpszClassName = "gtkstatusicon-observer";
wclass.lpfnWndProc = wndproc;
if (!klass)
return NULL;
- hwnd = CreateWindow (MAKEINTRESOURCE(klass),
+ hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 1, 1, NULL, NULL,
hmodule, NULL);
g_warning ("%s:%d:Shell_NotifyIcon(NIM_ADD) failed", __FILE__, __LINE__-2);
priv->nid.hWnd = NULL;
}
+
+ status_icons = g_slist_append (status_icons, status_icon);
+
#endif
#ifdef GDK_WINDOWING_QUARTZ
GObjectConstructParam *construct_params)
{
GObject *object;
+#ifdef GDK_WINDOWING_X11
GtkStatusIcon *status_icon;
GtkStatusIconPrivate *priv;
-
+#endif
+
object = G_OBJECT_CLASS (gtk_status_icon_parent_class)->constructor (type,
n_construct_properties,
construct_params);
DestroyIcon (priv->nid.hIcon);
gtk_widget_destroy (priv->dummy_widget);
+
+ status_icons = g_slist_remove (status_icons, status_icon);
#endif
#ifdef GDK_WINDOWING_QUARTZ
g_object_notify (G_OBJECT (status_icon), "orientation");
}
-#endif
-
static gboolean
gtk_status_icon_key_press (GtkStatusIcon *status_icon,
GdkEventKey *event)
emit_popup_menu_signal (status_icon, 0, gtk_get_current_event_time ());
}
+#endif
+
static gboolean
gtk_status_icon_button_press (GtkStatusIcon *status_icon,
GdkEventButton *event)